﻿// Decompiled with JetBrains decompiler
// Type: TaleWorlds.CampaignSystem.LogEntries.DefeatCharacterLogEntry
// Assembly: TaleWorlds.CampaignSystem, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null
// MVID: E85F8C15-4DF6-4E9C-A58A-29177E40D07A
// Assembly location: D:\steam\steamapps\common\Mount & Blade II Bannerlord\bin\Win64_Shipping_Client\TaleWorlds.CampaignSystem.dll

using Helpers;
using System.Collections.Generic;
using TaleWorlds.Localization;
using TaleWorlds.SaveSystem;

#nullable disable
namespace TaleWorlds.CampaignSystem.LogEntries
{
  public class DefeatCharacterLogEntry : LogEntry
  {
    [SaveableField(200)]
    public readonly Hero WinnerHero;
    [SaveableField(201)]
    public readonly Hero LoserHero;

    internal static void AutoGeneratedStaticCollectObjectsDefeatCharacterLogEntry(
      object o,
      List<object> collectedObjects)
    {
      ((LogEntry) o).AutoGeneratedInstanceCollectObjects(collectedObjects);
    }

    protected override void AutoGeneratedInstanceCollectObjects(List<object> collectedObjects)
    {
      base.AutoGeneratedInstanceCollectObjects(collectedObjects);
      collectedObjects.Add((object) this.WinnerHero);
      collectedObjects.Add((object) this.LoserHero);
    }

    internal static object AutoGeneratedGetMemberValueWinnerHero(object o)
    {
      return (object) ((DefeatCharacterLogEntry) o).WinnerHero;
    }

    internal static object AutoGeneratedGetMemberValueLoserHero(object o)
    {
      return (object) ((DefeatCharacterLogEntry) o).LoserHero;
    }

    public DefeatCharacterLogEntry(Hero winner, Hero loser)
    {
      this.WinnerHero = winner;
      this.LoserHero = loser;
    }

    public override ImportanceEnum GetImportanceForClan(Clan clan)
    {
      return this.WinnerHero.Clan == clan || this.LoserHero.Clan == clan ? ImportanceEnum.SlightlyImportant : ImportanceEnum.Zero;
    }

    public override void GetConversationScoreAndComment(
      Hero talkTroop,
      bool findString,
      out string comment,
      out ImportanceEnum score)
    {
      score = ImportanceEnum.Zero;
      comment = "";
      if (this.WinnerHero == Hero.MainHero)
      {
        if (this.LoserHero != talkTroop)
          return;
        score = ImportanceEnum.SlightlyImportant;
        if (!findString)
          return;
        comment = "str_comment_you_defeated_me_in_single_combat";
      }
      else
      {
        if (this.LoserHero != Hero.MainHero || this.WinnerHero != talkTroop)
          return;
        score = ImportanceEnum.SlightlyImportant;
        if (!findString)
          return;
        comment = "str_comment_i_defeated_you_in_single_combat";
      }
    }

    public override string ToString()
    {
      TextObject parent = new TextObject("{=!}{LOSER.NAME} defeated by {WINNER.NAME}.");
      StringHelpers.SetCharacterProperties("WINNER", this.WinnerHero.CharacterObject, parent);
      StringHelpers.SetCharacterProperties("LOSER", this.LoserHero.CharacterObject, parent);
      return parent.ToString();
    }
  }
}
